﻿using Md.Api.Model;
using Md.Api.Model.Manage.MdUserExperiencer.Request;
using Md.Api.Service.Manage.MdUserExperiencer;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Manage;
/// <summary>
/// 用户体验师
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/manage/md/userExperiencer")]
public class MdUserExperiencerController : ControllerBase
{
    /// <summary>
    /// 通过用户编号检查用户是否申请过体验师服务
    /// </summary>
    public CheckMdUserExperiencerByUserIdService checkMdUserExperiencerByUserIdService { get; set; }
    /// <summary>
    /// 通过用户编号检查用户是否申请过体验师
    /// </summary>
    /// <param name="userId">用户编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("check/apply/{userId}")]
    public async Task<ResponseMessageModel> CheckMdUserExperiencerByUserId(long userId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestCheckMdUserExperiencerByUserIdModel();

        model.UserId = userId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => checkMdUserExperiencerByUserIdService.Execute(model));
    }

    /// <summary>
    /// 通过编号删除体验师服务
    /// </summary>
    public DeleteMdUserExperiencerByIdService deleteMdUserExperiencerByIdService { get; set; }
    /// <summary>
    /// 通过编号删除体验师
    /// </summary>
    /// <param name="ids">体验师编号多个逗号分割（1,2,3...）</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpDelete("{ids}")]
    public async Task<ResponseMessageModel> DeleteMdUserExperiencerById(string ids, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestDeleteMdUserExperiencerByIdModel();

        model.Ids = ids;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => deleteMdUserExperiencerByIdService.Execute(model));
    }

    /// <summary>
    /// 添加体验师服务
    /// </summary>
    public InsertMdUserExperiencerService insertMdUserExperiencerService { get; set; }
    /// <summary>
    /// 添加体验师
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertMdUserExperiencer([FromBody] RequestInsertMdUserExperiencerModel model)
    {
        return await Task.Run(() => insertMdUserExperiencerService.Execute(model));
    }

    /// <summary>
    /// 通过编号更新体验师服务
    /// </summary>
    public UpdateMdUserExperiencerByIdService updateMdUserExperiencerByIdService { get; set; }
    /// <summary>
    /// 通过编号更新体验师
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPut]
    public async Task<ResponseMessageModel> UpdateMdUserExperiencerById([FromBody] RequestUpdateMdUserExperiencerByIdModel model)
    {
        return await Task.Run(() => updateMdUserExperiencerByIdService.Execute(model));
    }

    /// <summary>
    /// 通过编号获取体验师详情服务
    /// </summary>
    public GetMdUserExperiencerByIdService getMdUserExperiencerByIdService { get; set; }
    /// <summary>
    /// 通过编号获取体验师详情
    /// </summary>
    /// <param name="userExperiencerId">体验师编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{userExperiencerId}")]
    public async Task<ResponseMessageModel> GetMdUserExperiencerById(long userExperiencerId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetMdUserExperiencerByIdModel();

        model.UserExperiencerId = userExperiencerId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getMdUserExperiencerByIdService.Execute(model));
    }

    /// <summary>
    /// 获取体验师列表服务
    /// </summary>
    public GetMdUserExperiencerListService getMdUserExperiencerListService { get; set; }
    /// <summary>
    /// 获取体验师列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost]
    public async Task<ResponseMessageModel> GetMdUserExperiencerList([FromBody] RequestGetMdUserExperiencerListModel model)
    {
        return await Task.Run(() => getMdUserExperiencerListService.Execute(model));
    }

    /// <summary>
    /// 分页获取体验师列表服务
    /// </summary>
    public GetMdUserExperiencerPageListService getMdUserExperiencerPageListService { get; set; }
    /// <summary>
    /// 分页获取体验师列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetMdUserExperiencerPageList([FromBody] RequestGetMdUserExperiencerPageListModel model)
    {
        return await Task.Run(() => getMdUserExperiencerPageListService.Execute(model));
    }
}

